    package com.ruoyi.web.controller.project;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.project.domain.entity.ProjectPay;
import com.ruoyi.project.domain.entity.ProjectPhase;
import com.ruoyi.project.domain.query.ProjectPayQuery;
import com.ruoyi.project.domain.query.ProjectPhaseQuery;
import com.ruoyi.project.service.IProjectPayService;
import com.ruoyi.project.service.IProjectPhaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;

    @RestController
    @RequestMapping("/project/phase")
    @Api(tags = "附件信息", description = "附件信息")
    public class ProjectPhaseController {


        @Resource
        private IProjectPhaseService service;

        @ApiOperation("分页")
        @GetMapping(value = "/list")
        public R getList(ProjectPhaseQuery query) {
            return R.ok(service.getList(query));
        }

        @ApiOperation("获取项目阶段")
        @GetMapping(value = "/getStatus")
        public R getPhaseStatus(ProjectPhaseQuery query) {
            return R.ok(service.getStatus(query));
        }


        @ApiOperation("新增")
        @PostMapping(value = "/save")
        public R add(@RequestBody ProjectPhase project) {
            return R.ok(service.addInfo(project));
        }


        @ApiOperation("新增")
        @PostMapping(value = "/saveSale")
        public R addSaleInfo(@RequestBody ProjectPhase project) {
            return R.ok(service.addSaleInfo(project));
        }


        @ApiOperation("修改")
        @PutMapping (value = "/update")
        public R update(@RequestBody ProjectPhase project) {
            Boolean b = service.updateInfo(project);
            if (!b){
                throw new RuntimeException("更新失败");
            }
            return R.ok(service.getById(project.getId()));
        }

        @ApiOperation("环节回退")
        @PostMapping (value = "/rollBackPhase")
        public R rollBackPhase(@RequestBody ProjectPhase project) {
          return R.ok(service.rollBackPhase(project));
        }


        @ApiOperation("删除")
        @DeleteMapping (value = "/{id}")
        public R delete(  @PathVariable("id") String id) {
            return R.ok(service.deleteInfo(id));
        }



        @ApiOperation("详情")
        @GetMapping(value = "/details")
        public R<ProjectPhase> getDetails(@RequestParam String id) {
            return R.ok(service.getById(id));
        }


        @GetMapping(value = "/getStepList")
        public R getStepList(ProjectPhaseQuery query) {
            return R.ok(service.getStepList(query));
        }



    }
